<!DOCTYPE html>
<!-- saved from url=(0084)file:///C:/Users/Administrator/Desktop/munker_app2019/widget/html/youquan/my_dt.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../font-icon/demo.css">
    <link rel="stylesheet" type="text/css" href="../../font-icon/iconfont.css">
    <script type="text/javascript" src="../../script/api.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
        <style>
            .fasong{
            width: 3.2rem;
            height: 1.6rem;
            background-color: #f84d1f;
            color:#fff;
            border:none;
            font-size: 0.8rem;
            }
            .close_word{
                color: #fff;
                float: left;
                font-size: 0.9rem;
                margin-left: 0.5rem
            }
            .get_coment{
                width: 94%;
                height:4rem;
                margin-left: 3.3%;
                background-color: #fff;
               
            }
            .get_coment textarea{
                width: 100%;
                height: 100%;
                font-size: 0.8rem;
                display: flex;
                flex-direction: row;
                flex-wrap: wrap;
                margin-top: 0.5rem;
            }
            body{
                background-color: #fff;
            }
            .zhuanfa_text{
                width: 100%;
                height:4.5rem;
                margin-top: 2rem;
                position:relative;
                background-color: #eeeeee;
            }
            .zhuanfa_text_div{
                width: 4.5rem;
                height: 4.5rem;
                background-color: black;
                position: absolute;
                
            }
            .zhuanfa_name{
                margin-left: 5rem;
                font-size: 0.8rem;
                font-weight: 650;
            }
            .som{
                display: flex;
                flex-direction: column;
               
            }
            .zhuanfa_text_neir{
                margin-left:5rem;
                flex-direction:row;
                width: 12rem;;
                height: 3rem;
                display: flex;
               
            }
            .zhuanfa_text_neir_1{
                width:12rem;
            color:#6c6c6c;
            word-break: break-all;
            
            text-overflow: ellipsis;
            
            display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
            
            -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
            
            -webkit-line-clamp: 3; /** 显示的行数 **/
            
            overflow: hidden;  /** 隐藏超出的内容 **/
            font-size: 0.75rem;
            line-height: 1rem;
            }
            .gongneng{
                width: 100%;
                height:6rem; 
                background-color: #fff;  
                margin-top: 6rem;
                display: flex;
                flex-direction: column;
                border-top: solid 0.05rem #eeeeee;
            }
            .one_weizhi_youquan{
                width: 90%;
                height: 50%;
                margin-left: 5%;
                background-color: #fff;
                border-bottom: solid 0.05rem #eeeeee;
                line-height: 3rem;
                color:#6c6c6c;
            }
            .img_box{
                width:30%;height: 4.5rem;background-color:  #ccc;margin-right: 1.5%;margin-left: 1.5%;margin-top: 4%;
            }
            #main{
                display: flex;flex-direction: row;flex-wrap: wrap;margin-left: 0;
            }
            .img_img{
                width: 100%;height: 100%; background-image: url('../../image/img_fabiao.png');background-size:cover;
            }
            .img_box1{

                width: 6.5rem;height: 6.5rem;background-color:  #eeeeee;margin-right: 0.5rem;
            }
            </style>
            </head><body>
                    <header id="header" class="aui-bar aui-bar-nav" style="background-color:  #ff9f00;height: 3rem">
                            <div class="close_word" onclick="api.closeWin()">取消</div>
                            <div class="aui-title">转发动态</div>
                           
                            
                            <div style="float: right;margin-right: 0.5rem;"><button class="fasong" onclick="fabiao()">发送</button></div>
                          
                    </header>
            
                    <div class="get_coment"><textarea id="demo" type="text" maxlength="50" placeholder="最多输入50个字..."></textarea><div>
                    
                   <div id="main">
                       <div class="img_box" id="i_one">
                            <img class="img_img">
                       </div>
                       
                   </div>
            
                    <div class="gongneng">
                        <!-- <div class="one_weizhi_youquan">
                            <span class="aui-iconfont aui-icon-location" style="font-size: 1rem;"></span>
                            <span style="font-size: 0.8rem;margin-left: 0.3rem;">所在位置</span>
                            
                            <span class="aui-iconfont aui-icon-right" style="font-size: 0.9rem;float: right;"></span>
                            <span style="float: right;margin-right: 0rem;font-size: 0.8rem;">武侯xxxx</span>
                        </div> -->
                        <div class="one_weizhi_youquan">
                            <span class="aui-iconfont aui-icon-my" style="font-size: 1rem;"></span>
                            <span style="font-size: 0.8rem;margin-left: 0.3rem;">谁可以看</span>
                            
                            <span class="aui-iconfont aui-icon-right" style="font-size: 0.9rem;float: right;"></span>
                            <!-- <span style="float: right;margin-right: 0rem;font-size: 0.8rem;">公开</span> -->
                           <div style="float: right;margin-right: 0rem;font-size: 0.8rem;margin-top: 0.5rem;">
                            <select id="test">
                                <option selected="selected" value="1">公开</option>
                                <option value="0">仅自己可见</option>
                            </select>
                           </div>
                            
                        </div>
                    </div>
            
<script type="text/javascript">
  var height_img = $('#i_one').css('width');
  
  $('.img_box').css('height',height_img);
 

var i=0;

 apiready = function() {
    $('body').on('click','.img_box',function(){
        var img=$(this).children('img');
        var cla=$(this)
        api.actionSheet({
            title: '上传图片',
            cancelTitle: '取消',
            buttons: ['拍照','从手机相册选择']
        }, function(ret, err) {
            if (ret) {
                getPicture(ret.buttonIndex,img,cla);
              
            }
        });

    });

    function getPicture(sourceType,img,cla) {
        
        if(sourceType==1){ // 拍照
            api.getPicture({
                sourceType: 'camera',
                encodingType: 'jpg',
                mediaValue: 'pic',
                allowEdit: false,
                destinationType: 'base64',
                       
                saveToPhotoAlbum: true
            }, function(ret, err) {
                if (ret) {
                        // $('#imgUp').attr('src', ret.base64Data)
                        var aa=ret.base64Data;
                        api.ajax({
                            timeout : 100,
                            method : 'post',
                            url : 'http://www.mk517.com/webApi/upimage.php',
                  data : {
                          files:{upfile : ret.data},
                          
                  },
                            dataType:'json',
                            async:true,
                        },function(ret,err){
                            api.hideProgress();
                        
                            img.attr('src','https://www.mk517.com/webApi/image/'+ret.img);
                            if(cla.is(':last-child'))
                                {
                                    if( img.attr('src')!=''&&$('.img_box').length < 9){
                                $api.byId('main').innerHTML += '<div class="img_box" >'+
                                                            '<img class="img_img">'+
                                                   ' </div>';
                                                   $('.img_box').css('height',height_img);             
                                }
                           
                                                  
                            }
                            
                           
                        })
                }else {
                    alert(JSON.stringify(err));
                }
            });
        }
        else if(sourceType==2){ // 从相机中选择
            api.getPicture({
                    sourceType: 'library',
                    encodingType: 'jpg',
                    mediaValue: 'pic',
                    destinationType: 'base64',
                    allowEdit: true,
                   
                   
                    destinationType: 'url',
                    
                }, function(ret, err) {
                    if (ret) {
                        // $('#imgUp').attr('src', ret.base64Data)
                        var aa=ret.base64Data;
                        api.ajax({
                            timeout : 100,
                            method : 'post',
                            url : 'http://www.mk517.com/webApi/upimage.php',
                  data : {
                          files:{upfile : ret.data},
                          
                  },
                            dataType:'json',
                            async:true,
                        },function(ret,err){
                            api.hideProgress();
                        
                               
                            img.attr('src','https://www.mk517.com/webApi/image/'+ret.img);
                            if(cla.is(':last-child'))
                                {
                                    if( img.attr('src')!=''&&$('.img_box').length < 9){
                                $api.byId('main').innerHTML += '<div class="img_box" >'+
                                                            '<img class="img_img">'+
                                                   ' </div>';
                                                   $('.img_box').css('height',height_img);             
                                }
                           
                                                  
                            }
                            
                            
                            
                        })
                    } else {
                        alert(JSON.stringify(err));
                    }
            });
        }
    }


  
 }



//发表
window.fabiao=function(){
var token = $api.getStorage('token');
var conten= $('#demo').val();
var open=$('#test').val();
var img=new Array();
var tr_img_src=$('.img_img').attr('src') ;
var arr =new Array();

    
$(".img_img").each(function() {   
    
        var src=$(this).attr("src");
        
     if (src==''||src == null||src == undefined){

     }else{
          arr=src.split("image/");
        
         img.push(arr[1]);  
     }
     
        
 });

// for(var l=0;;l<$('.img_img').length;l++   ){
//     var tr_img_src=$('.img_img')[i].attr('src') ;
// alert(tr_img_src);
// }

if(conten==''||conten==null){
    alert('请说点什么吧');
    
}else{
    var token = {
                token: token,
                content:conten,
                open:open,
                img:img
            };
        api.ajax({
            url: 'http://www.mk517.com/webApi/upload_img.php',
            method: 'post',
            "headers": {
                "Content-Type": "application/json"
            },
            dataType: "json",
            data: {
                body: token
            }
        }, function(ret, err) {
            // alert(JSON.stringify(ret));
            if (ret) {
             if(ret.sta==1){
                 alert('发表成功!');
                 api.closeWin();
             }else{
                 alert('发表失败!')
             }
                
             }else {
                alert(JSON.stringify(err));
            }
        });


}
 	


}







    // // 界面文字
   
    //   // 上传图片
    // function showAction(){
    //     api.actionSheet({
    //         title: '上传图片',
    //         cancelTitle: '取消',
    //         buttons: ['拍照','从手机相册选择']
    //     }, function(ret, err) {
    //         if (ret) {
    //             getPicture(ret.buttonIndex);
    //         }
    //     });
    // }
    // function getPicture(sourceType) {
    //     if(sourceType==1){ // 拍照
    //         api.getPicture({
    //             sourceType: 'camera',
    //             encodingType: 'jpg',
    //             mediaValue: 'pic',
    //             allowEdit: false,
    //             destinationType: 'base64',
    //             quality: 90,        
    //             saveToPhotoAlbum: true
    //         }, function(ret, err) {
    //             if (ret) {
    //                $('#imgUp').attr('src', ret.base64Data);
    //             }else {
    //                 alert(JSON.stringify(err));
    //             }
    //         });
    //     }
    //     else if(sourceType==2){ // 从相机中选择
    //         api.getPicture({
    //                 sourceType: 'library',
    //                 encodingType: 'jpg',
    //                 mediaValue: 'pic',
    //                 destinationType: 'base64',
    //                 allowEdit: true,
    //                 quality: 50,
    //                 targetWidth: 100,
    //                 destinationType: 'url',
    //                 targetHeight: 100
    //             }, function(ret, err) {
    //                 if (ret) {
    //                     // $('#imgUp').attr('src', ret.base64Data)
    //                     var aa=ret.base64Data;
    //                     api.ajax({
    //                         timeout : 100,
    //                         method : 'post',
    //                         url : 'http://www.mk517.com/webApi/upimage.php',
    //               data : {
    //                       files:{upfile : ret.data},
                          
    //               },
    //                         dataType:'json',
    //                         async:true,
    //                     },function(ret,err){
    //                         api.hideProgress();
                        
    //                             alert(ret.img);
                            
                           
    //                     })
    //                 } else {
    //                     alert(JSON.stringify(err));
    //                 }
    //         });
    //     }
    // }


</script>
</div></div></body></html>